//
//  ChannelMineViewController.m
//  FNer
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 刘志强. All rights reserved.
//

#import "ChannelMineViewController.h"
#import "DataHandle.h"
#import "MyChannelTableViewCell.h"
#import "CommunityDetailViewController.h"
@interface ChannelMineViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,retain)NSMutableArray *myarray;
@property(nonatomic,retain)CommunityDetailViewController *communityDetailVC;
@end

@implementation ChannelMineViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.myarray=[NSMutableArray array];
    NSMutableDictionary *dic = [[DataHandle shareDataHandle] selectChannel];
    self.myarray = [dic objectForKey:@"array"];

   
    self.view.backgroundColor = [UIColor colorWithRed:231 / 255.0 green:231 / 255.0 blue:231 / 255.0 alpha:1];
    UIImageView *tempImageView = [[UIImageView alloc] initWithFrame:CGRectMake(130 * XWIDTH, 200 * XHIGHT, 120 * XWIDTH, 90 * XHIGHT)];
    tempImageView.image = [UIImage imageNamed:@"我的频道-空白处@2x.png"];
    [self.view addSubview:tempImageView];
    UILabel *atempLable = [[UILabel alloc] initWithFrame:CGRectMake(130 * XWIDTH, 320 * XHIGHT, 156 + XWIDTH, 30 * XHIGHT)];
    atempLable.text = @"页面还很空~ ^.^";
    atempLable.textColor = [UIColor lightGrayColor];
    [self.view addSubview:atempLable];
    atempLable.font = [UIFont systemFontOfSize:17 * XWIDTH];
    
    UILabel *btempLabel = [[UILabel alloc] initWithFrame:CGRectMake( 65 * XWIDTH, 345 * XHIGHT, 300 * XWIDTH, 30 * XHIGHT)];
    btempLabel.text = @"可以到热门频道里添加更多订阅";
    btempLabel.textColor = [UIColor lightGrayColor];
    [self.view addSubview:btempLabel];
    btempLabel.font = [UIFont systemFontOfSize:17 * XWIDTH];
    
    self.myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HIGHT - 49 - 64) style:UITableViewStylePlain];
    [self.view addSubview:self.myTableView];
    self.myTableView.backgroundColor = [UIColor clearColor];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.myTableView.bounces = NO;
}




-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    NSMutableDictionary *dic = [[DataHandle shareDataHandle] selectChannel];
    self.myarray = [dic objectForKey:@"array"];
    return self.myarray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"cell";
    MyChannelTableViewCell *myshequCell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (myshequCell == nil) {
        myshequCell = [[MyChannelTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    myshequCell.backgroundColor = [UIColor whiteColor];
    
    NSMutableDictionary *dic = [[DataHandle shareDataHandle] selectChannel];
    NSMutableArray *dingyueArray = [dic objectForKey:@"array"];
    myshequCell.achannel = [dingyueArray objectAtIndex:indexPath.row];
    
    myshequCell.backgroundColor = [UIColor colorWithRed:231 / 255.0 green:231 / 255.0 blue:231 / 255.0 alpha:1];
    
    return myshequCell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 110 * XHIGHT;
}
//我的频道点击触发事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.myTableView deselectRowAtIndexPath:indexPath animated:YES];
    
    NSMutableDictionary *dic = [[DataHandle shareDataHandle] selectChannel];
    NSMutableArray *array = [dic objectForKey:@"array"];
    
    self.communityDetailVC = [[CommunityDetailViewController alloc] init];
//    [self.myAgent hidesBottomBar];
//    self.communityDetailVC.hidesBottomBarWhenPushed = YES;
    [SHAREDAPPDELE.myTB isHiddenTabBar:YES withViewController:self.communityDetailVC];
    [self.navigationController pushViewController:self.communityDetailVC animated:YES];
    
    self.communityDetailVC.achannel = [array objectAtIndex:indexPath.row];
}

    


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
